*****************************************************************
*****************************************************************
*** 0. General settings
*****************************************************************
*****************************************************************

* clear
clear
clear 		mata
mat 		drop _all

* set path
global		path	""					



use "$path/0 Data/_Processed/US_Revolver_regression", clear

sum tranche_amount_converted
gen tranche_bn = tranche_amount_converted / 1000

drop if year < 2018 | year == 2022



preserve


* 1. Quarterly credit line issuances 

collapse (sum) tranche_bn (first) tranche_active_date , by(qdate)

gen pre_covid = (tranche_active_date <= mdy(6,30,2020))

summarize tranche_bn if pre_covid == 1 , meanonly
gen mean_tranche_bn_pre = r(mean)

summarize tranche_bn if pre_covid == 0 , meanonly
gen mean_tranche_bn_post = r(mean)

sum mean_tranche_bn_pre mean_tranche_bn_post

/*

    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
mean_tranc~e |         16    455.7711           0   455.7711   455.7711
mean_tranc~t |         16    475.5608           0   475.5608   475.5608


*/
tsset qdate

twoway  (tsline tranche_bn) (tsline mean_tranche_bn_post if pre_covid== 0) (tsline mean_tranche_bn_pre if pre_covid== 1), ///
	legend(label(1 "Credit Line Amount")label(2 "Mean Pre-COVID")label(3 "Mean Post-COVID")) ///
 	scheme(s2mono) ///
	xtitle("Date")		///
	ytitle("Quarterly credit line issuances (USD bn)")		///^
	ylabel(, angle(horizontal)) ///
	note("")   ///			
	graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
	
graph export "$path/05 Figures/Figure 5 Panel A.png", as(png) name("Graph") replace



restore



** Spread



preserve

collapse (mean) AISD AISU UFR (first) tranche_active_date , by(qdate)

gen pre_covid = (tranche_active_date <= mdy(6,30,2020))

summarize AISD if pre_covid == 1 , meanonly
gen mean_AISD_pre = r(mean)

summarize AISD if pre_covid == 0 , meanonly
gen mean_AISD_post = r(mean)

summarize AISU if pre_covid == 1 , meanonly
gen mean_AISU_pre = r(mean)

summarize AISU if pre_covid == 0 , meanonly
gen mean_AISU_post = r(mean)

summarize UFR if pre_covid == 1 , meanonly
gen mean_UFR_pre = r(mean)

summarize UFR if pre_covid == 0 , meanonly
gen mean_UFR_post = r(mean)

sum mean_AISD_pre mean_AISD_post mean_AISU_pre mean_AISU_post mean_UFR_pre mean_UFR_post

/*
    Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
mean_AISD_~e |         16    259.4487           0   259.4487   259.4487
mean_AISD_~t |         16     272.025           0    272.025    272.025
mean_AISU_~e |         16    28.00426           0   28.00426   28.00426
mean_AISU_~t |         16    28.26997           0   28.26997   28.26997
mean_UFR_pre |         16    107.3929           0   107.3929   107.3929
-------------+---------------------------------------------------------
mean_UFR_p~t |         16    83.02778           0   83.02778   83.02778

*/


tsset qdate

twoway  (tsline AISD) (tsline mean_AISD_post if pre_covid== 0) (tsline mean_AISD_pre if pre_covid== 1), ///
	legend(label(1 "AISD")label(2 "Mean AISD Pre-COVID")label(3 "Mean AISD Post-COVID")) ///
 	scheme(s2mono) ///
	xtitle("Date")		///
	ytitle("Quarterly AISD (bps)")		///^
	ylabel(, angle(horizontal)) ///
	note("")   ///			
	graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
	
graph export "$path/05 Figures/Figure 5 Panel B.png", as(png) name("Graph") replace

twoway  (tsline AISU) (tsline mean_AISU_post if pre_covid== 0) (tsline mean_AISU_pre if pre_covid== 1), ///
	legend(label(1 "AISU")label(2 "Mean AISU Pre-COVID")label(3 "Mean AISU Post-COVID")) ///
 	scheme(s2mono) ///
	xtitle("Date")		///
	ytitle("Quarterly AISU (bps)")		///^
	ylabel(, angle(horizontal)) ///
	note("")   ///			
	graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
	
graph export "$path/05 Figures/Figure 5 Panel C.png", as(png) name("Graph") replace

twoway  (tsline UFR) (tsline mean_UFR_post if pre_covid== 0) (tsline mean_UFR_pre if pre_covid== 1), ///
	legend(label(1 "UFR")label(2 "Mean UFR Pre-COVID")label(3 "Mean UFR Post-COVID")) ///
 	scheme(s2mono) ///
	xtitle("Date")		///
	ytitle("Quarterly UFR (bps)")		///^
	ylabel(, angle(horizontal)) ///
	note("")   ///			
	graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white))
	
graph export "$path/05 Figures/Figure 5 Panel D.png", as(png) name("Graph") replace

restore




